$(function() {
	$('#my-table').dataTable().fnDestroy();
	oTable = $('#my-table').DataTable({
		"processing" : true, //加载数据时显示正在加载信息   
		"serverSide" : true, //指定从服务器端获取数据   
		"searching" : false,
		"lengthChange" : false, //用户不可改变每页显示数量   
		"ordering" : false,
		"aLengthMenu" : [ 10 ],//设置一页展示10条记录

		"ajax" : {
			"url" : "/btsb/mxlist",
			"dataType" : "json",
			"type" : "post",
			"dataSrc" : "rowsData",
			"data" : function(d) {
				d.ishc = $('#ishc').val();
				d.hzdh = $('#hzdh').val();
			}
		},
		"columns" : [{
			"data" : null
		}, {
			"data" : "yslx"
		}, {
			"data" : "xh"
		}, {
			"data" : "hwlx"
		}, {
			"data" : "xx"
		}, {
			"data" : "crtlsj"
		}, {
			"data" : "tlhph"
		}, {
			"data" : "crgksj"
		}, {
			"data" : "hwydh"
		}, {
			"data" : "hgsbdh"
		}, {
			"data" : "jjyy"
		},  {
			"data" : "id"
		} ],
		"columnDefs" : [{
			"targets" : 0,
			"width" : "4%",
			"render" : function(data, type, row, meta) {
				// 显示行号  
                var startIndex = meta.settings._iDisplayStart;  
                return startIndex + meta.row + 1;  
			}
		}, {
			"targets" : 1,
			"width" : "6%",
			"render" : function(data, type, row, meta) {
				if(data=="1"){
					return "铁水";
				}else if(data=="2"){
					return "水铁";
				}else{
					return "暂无";
				}
			}
		}, {
			"targets" : 2,
			"width" : "10%"			
		}, {
			"targets" : 3,
			"width" : "8%",
			"render" : function(data, type, row, meta) {
				return (!row.hwlxinfoVO) ? "暂无" : row.hwlxinfoVO.hwlxmc;
			}
		}, {
			"targets" : 4,
			"width" : "5%",
			"render" : function(data, type, row, meta) {
				return (!row.xxinfoVO) ? "暂无" : row.xxinfoVO.xxmc;
			}
		}, {
			"targets" : 5,
			"width" : "12%",
			"render" : function(data, type, row, meta) {
				return date2String(data);
			}
		}, {
			"targets" : 6,
			"width" : "10%"			
		},{
			"targets" : 7,
			"width" : "10%",
			"render" : function(data, type, row, meta) {	
				return date2String(data);
			}
		}, {
			"targets" : 8,
			"width" : "10%"			
		}, {
			"targets" : 9,
			"width" : "8%"			
		}, {
			"targets" : 10,
			"width" : "10%"			
		},{
			"targets" : 11,
			"width" : '7%',
			"data" : "id",
			"render" : function(data, type, row, meta) {
				var buttons = "";	
				if(meta.settings.json.attach.hzzt==0||meta.settings.json.attach.hzzt==4){
					buttons = "<a name='editbtn' href='/btsb/mxeditindex?id="+data+"' class='am-btn am-btn-xs am-text-secondary'><span class='am-icon-newspaper-o'></span> 编辑</a>";	
					buttons += "<a name='editbtn' onclick='del("+data+")' class='am-btn am-btn-xs am-text-secondary'><span class='am-icon-newspaper-o'></span> 删除</a>";
				}			
				return buttons;
			}
		}]
	});
})

function del(mxid){
	$.ajax( {  
        type : 'POST',  
        url : '/btsb/del',
        data: 'id='+mxid,
        dataType:"json",  
        success : function(data) {  
        	var status = data.status;
        	if(status==0){   		
        		alert('删除成功');
        		search();
        	}
        },  
        error : function(data) {  
          alert("失败");
        }  
      });
}